home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / misc / amag / 12b92.lha / Tips & Tricks / Busy Pointer (C, BASIC) / ClockPointer.c < prev    next >
C/C++ Source or Header  |  1992-11-02  |  2KB  |  77 lines

  1. /*
  2.    ClockPointer.c - verwandelt den Mauszeiger in eine Uhr
  3.    Aufruf mit Aztec V3.6:     cc ClockPointer.c +l
  4.                               ln ClockPointer.o -lc32
  5.                               ClockPointer
  6. */
  7.  
  8. #include <functions.h>
  9. #include <exec/memory.h>
  10. #include <graphics/view.h>
  11. #include <intuition/intuitionbase.h>
  12. #include <hardware/cia.h>
  13. struct GfxBase *GfxBase;
  14. struct IntuitionBase *IntuitionBase;
  15. struct ViewPort *ViewPort;
  16. struct Window *Window;
  17. USHORT *Pointer;
  18. ULONG col1,col2,col3;
  19. USHORT PointerData[]=        /* Daten des Uhr-Mauszeigers */
  20.  {
  21.   0,0,
  22.   0x0,0x7C0, 0x0,0x100, 0x0,0x7C0,
  23.   0x7C0,0x1830, 0x1FF0,0x2108, 0x3FF8,0x4104,
  24.   0x3FF8,0x4104, 0x7FFC,0x8102, 0x7FFC,0x8102, 
  25.   0x7FFC,0x81F2, 0x7FFC,0x8002, 0x7FFC,0x8002, 
  26.   0x3FF8,0x4004, 0x3FF8,0x4004, 0x1FF0,0x2008, 
  27.   0x7C0,0x1830, 0x0,0x7C0, 0x0,0x820, 
  28.   0x0,0x1830
  29.  };
  30.  
  31. BOOL SetClockPointer(Window)    /* setzten des Uhr-Mauszeigers */
  32. struct Window *Window;
  33. {
  34.  if (Pointer=AllocMem(sizeof(PointerData),MEMF_CHIP))
  35.  {
  36.   ViewPort=(struct ViewPort *)ViewPortAddress(Window);
  37.   col1=GetRGB4(ViewPort->ColorMap,17);    /* Farben des alten Zeigers retten */
  38.   col2=GetRGB4(ViewPort->ColorMap,18);
  39.   col3=GetRGB4(ViewPort->ColorMap,19);
  40.   SetRGB4(ViewPort,17,15,15,15);    /* Farben für neuen Zeiger setzen */
  41.   SetRGB4(ViewPort,18,2,3,11);
  42.   SetRGB4(ViewPort,19,1,2,4);
  43.   CopyMem(PointerData,Pointer,sizeof(PointerData)); /* Daten ins Chip Mem */
  44.   SetPointer(Window,Pointer,18,16,1,1);            /* Pointer setzen */
  45.   return(1);
  46.  }
  47.  return(0);
  48. }
  49.  
  50. void ClearClockPointer(Window)        /* alten Zeiger wieder herstellen */
  51. struct Window *Window;
  52. {
  53.  ClearPointer(Window);                /* eigenen Zeiger löschen */
  54.  SetRGB4(ViewPort,17,(col1>>8)&15,(col1>>4)&15,col1&15);
  55.  SetRGB4(ViewPort,18,(col2>>8)&15,(col2>>4)&15,col2&15);
  56.  SetRGB4(ViewPort,19,(col3>>8)&15,(col3>>4)&15,col3&15);
  57.  FreeMem(Pointer,sizeof(PointerData));        /* Speicher freigeben */
  58. }
  59.  
  60. void main()
  61. {
  62.  IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0);
  63.  GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0);
  64.  if (IntuitionBase && GfxBase)
  65.  {
  66.   Window=IntuitionBase->ActiveWindow;
  67.   if (SetClockPointer(Window))        /* Uhr-Mauszeiger setzen */
  68.   {
  69.    puts("Warten beenden mit Mausklick !");
  70.    while (ciaa.ciapra&64);        /* auf MausKlick warten */
  71.    ClearClockPointer(Window);        /* Uhr-Mauszeiger löschen */
  72.   }
  73.  }
  74.  if (IntuitionBase) CloseLibrary(IntuitionBase);
  75.  if (GfxBase) CloseLibrary(GfxBase);
  76. }
  77.